package cn.dyw.simpletest;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MainActivity extends AppCompatActivity {

    private MyDatabaseHelper databaseHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        databaseHelper = new MyDatabaseHelper(this, "data.db", null, 1);
        SQLiteDatabase sqLiteDatabase = databaseHelper.getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put("name", "空气质量");
        values.put("dataNum", 150);
        values.put("healthy", "正常");
        values.put("time", new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
        sqLiteDatabase.insert("data", null, values);
    }
}
